package bTree.LeetCode;

import java.util.List;

public class 分隔链表 {
    public ListNode partition(ListNode head, int x) {
        ListNode dummy=new ListNode(-1);
        ListNode p1=dummy;
        ListNode p2=head;
        while (p2!=null){
            if(p2.val<x){
                p1.next=new ListNode(p2.val);
                p1=p1.next;
            }
            p2=p2.next;
        }
        ListNode p3=head;
        while (p3!=null){
            if(p3.val>=x){
                p1.next=new LIstNode(p3);
                p1=p1.next;
            }
            p3=p3.next;
        }
        return dummy.next;
    }
}